<% content_for :css do %>
  <%= stylesheet_link_tag 'top_hot_tools','sub_nav_bar','tools_show' %>
  <%= stylesheet_link_tag 'tools_zhui_tian_ya_show' if @tool.code.zhui_tian_ya? %>
<% end %>
<% content_for :javascript do %>
  <script type="text/javascript" charset="utf-8">    
    function show_or_hide(name)
    {
      $$('#body div.sub_nav_bar div.item').each( function(item) {
        item.className = 'item';        
      });
      $('sub_nav_bar_item_' + name).className = 'h item';
      
      $$('#tools div.tool').each( function(item) {
        item.className = 'h tool';        
      });
      $(name).className = 'tool';
    }
    
    function share()
    {
      if($F('share_to_others') == 'kaixin001')
      {
        window.open("http://www.kaixin001.com/repaste/share.php?rurl=<%= tool_url @tool %>&rtitle=麦吐司网-为您提供有趣、实用、免费的在线工具!-<%= @tool.name %>");
      }
      if($F('share_to_others') == 'renren')
      {
        window.open("http://share.renren.com/share/buttonshare.do?link=<%= tool_url @tool %>&title=麦吐司网-为您提供有趣、实用、免费的在线工具!-<%= @tool.name %>");
      }
      if($F('share_to_others') == 'weibo')
      {
        window.open("http://v.t.sina.com.cn/share/share.php?c=&url=<%= tool_url @tool %>&title=麦吐司网-为您提供有趣、实用、免费的在线工具!-<%= @tool.name %>");
      }
      if($F('share_to_others') == 'douban')
      {
        window.open("http://www.douban.com/recommend/?url=<%= tool_url @tool %>&title=麦吐司网-为您提供有趣、实用、免费的在线工具!-<%= @tool.name %>");
      }
      if($F('share_to_others') == 'baidu')
      {
        window.open("http://apps.hi.baidu.com/share/?url=<%= tool_url @tool %>&title=麦吐司网-为您提供有趣、实用、免费的在线工具!-<%= @tool.name %>");
      }
      if($F('share_to_others') == 'qqzone')
      {
        window.open("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=<%= tool_url @tool %>&title=麦吐司网-为您提供有趣、实用、免费的在线工具!-<%= @tool.name %>");
      }
    }
    
    <% if @tool.code.zhui_tian_ya? %>
    function go_to(page_num)
    {
      $('page').value = page_num;
      searching();
    }
    
    function search_by_hot_post_type_id(type_id)
    {
      $('hot_post_type_id').value = type_id;
      searching();
    }
    
    function searching()
    {
      <%= remote_function :update => 'new_and_hot',
            :url => new_and_hot_tools_zhui_tian_ya_hot_posts_url,
            :method => :get,
            :loading => 'loading()',
            :with => "Form.serialize('search_form') + '&' + Form.serialize('order_by_form')"
      %>
    }

    function searching_without_loading()
    {
      <%= remote_function :update => 'new_and_hot',
            :url => new_and_hot_tools_zhui_tian_ya_hot_posts_url,
            :method => :get,
            :with => "Form.serialize('search_form') + '&' + Form.serialize('order_by_form')"
      %>
    }
    
    function loading() 
    {
      <%= normal_loading('new_hot_posts', :width_from => 'new_hot_posts', :height => '500px') %>
    }

    function my_zhuis_without_loading()
    {
      <%= remote_function :update => :my_zhui,
            :url => my_zhui_tools_zhui_tian_ya_hot_posts_url,
            :method => :get,
            :with => "'&hot_post_type_id=' + $F('type_id')"
      %>
    }

    function my_zhuis()
    {
      <%= remote_function :update => :my_zhui,
            :url => my_zhui_tools_zhui_tian_ya_hot_posts_url,
            :method => :get,
            :loading => normal_loading('my_zhui',:height => '500px'),
            :with => "'&hot_post_type_id=' + $F('type_id')"
      %>
    }
    <% end %>
  </script>
<% end %>
<div class='line'>
  <%= render :file => 'homes/_top_hot_tools.html', :locals => { :how_many => 10 } %>
  <div id="main">
    <div class='head'>
      <div  class="logo_and_tool">
        <div class='logo'>
          <%= tool_logo_image_tag @tool, :width => 280 %>
        </div>
        <% if has_logined_by_admin? %>
        <div class="tool">
          <%= link_to_new_or_edit_tool_logo @tool %>
        </div>
        <% end %>
      </div>
      <div class='info'>
        <div class='top_corner'>          
          <div class="left"></div>
          <div class="right"></div>
        </div>
        <div class='body'>
          <div class='title'>
            <div class='h1'><%= @tool.name %><span>(版本：<%= @tool.version %>)</span></div>
          </div>
          <div class='line'>
            <dl>
              <dt>分&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;类：</dt><dd><%= @tool.tool_type.name %></dd>
            </dl>
          </div>
          <div class='line'>
            <dl>
              <dt>关&nbsp;&nbsp;键&nbsp;&nbsp;词：</dt><dd><%= @tool.key_words %></dd>
            </dl>
          </div>
          <div class='line'>
            <dl>
              <dt>出炉时间：</dt><dd><%= @tool.released_on %></dd>
            </dl>
          </div>
          <div class='line'>
            <dl>
              <dt>月&nbsp;&nbsp;消&nbsp;&nbsp;费：</dt><dd class='money' title='每月扣减<%= @tool.month_fare %>麦粒'><%= @tool.month_fare %><%= image_tag 'base/money_32.png', :size => '14x14', :alt => '麦粒', :title => '麦粒' %><%= link_to_function '[?]',helps_url(:id => 12 ), :title => '什么是麦粒?', :target => :_blank , :class => :help %></dd>
            </dl>
          </div>
          <div class='line' style="display:none;">
            <dl>
              <dt>美味指数：</dt>
              <dd>
                <% @tool.option_value.to_i.to_i.times do %><b class='star_on'>★</b><% end %><% (5 - @tool.option_value.to_i).times do %><b class='star_off'>☆</b><% end %>
              </dd>
              <dd class='option'>(<b><%= @tool.options_count %></b>人参与<%= link_to "评分", "index", :title => '评价吐司的美味程度' %>)</dd>
            </dl>
          </div>
          <div class='line'>
            <dl>
              <dt>享&nbsp;&nbsp;用&nbsp;&nbsp;度：</dt>
              <dd class='using'>
                <b><%= @tool.user_tool_settings_count %></b>人正在享用<%#= link_to "都有谁？", "index" %>
              </dd>
           </dl>
          </div>
          <div class='line'>
            <dl>
              <dt>关&nbsp;&nbsp;注&nbsp;&nbsp;度：</dt>
              <dd class='care'>
                <b><%= @tool.carers_count %></b>人关注过<%#= link_to "都有谁？", "index" %>
              </dd>
           </dl>
          </div>
          <div class='line'>
            <dl>
              <dt>简&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;介：</dt>
              <dd class='synopsis'>
                <%= @tool.synopsis %>
              </dd>
           </dl>
          </div>
          <div class='line'>
            <dl>         
              <dt>享用方式：</dt> 
              <dd class='funcs'>
                <%= supports_web( :size => '18x18') if @tool.support_web? %>
                <%= supports_sms(:size => '18x18') if @tool.support_sms? %>
                <%= supports_email(:size => '18x18') if @tool.support_email? %>
              </dd>
            </dl>
          </div>
          <div class='line'>
            <div class='enjoy_or_not'>
            <% if has_logined_by_user? %>
              <% if @tool.flash?  %>
                <%= link_to image_tag("tools/enjoy.jpg"), 
                      tools_flash_url(@tool), 
                      :target => :_blank,
                      :title => '直接开吃！'                 
                %>
              <% elsif @tool.set_by_current_user? %>
                <% if @tool.popup? %>
              	<%= link_to image_tag("tools/has_enjoyed.jpg"), 
                      instance_eval("tools_#{@tool.code}_url(:default)"), 
                      :target => :_blank,
                      :title => '试吃看看'
                %> 
                <% else %>
                  <% if @tool.code.zhui_tian_ya? %>
                    <%= link_to image_tag("tools/has_enjoyed.jpg"), 
                          tools_zhui_tian_ya_hot_posts_url,
                          :target => :_blank,
                          :title => '看看我的追天涯'                      
                    %> 
                  <% elsif @tool.code.open_apis? %>
                    <%= link_to image_tag("tools/has_enjoyed.jpg"), 
                          tools_zhui_tian_ya_hot_posts_url,
                          :target => :_blank,
                          :title => '如何使用open api'
                    %> 
                  <% else %>
                    <%= link_to_function image_tag("tools/has_enjoyed.jpg"), 
                          "show_or_hide('my_setting');Effect.ScrollTo('sub_nav_bar_item_my_setting',{during:2})", 
                          :title => '看看我的偏好设置'                      
                    %> 
                  <% end %>
                <% end %>
              <% else %>    
                <% if @tool.popup? %>          
                <%= link_to image_tag("tools/enjoy.jpg"), 
                      instance_eval("tools_#{@tool.code}_url(:default)"), 
                      :target => :_blank,
                      :title => '简单的设置，即可享用此大餐' 
                %>
                <% else %>
                <%= link_to_function image_tag("tools/enjoy.jpg"), 
                      "$('new_setting').onclick();show_or_hide('my_setting');Effect.ScrollTo('sub_nav_bar_item_my_setting',{during:2})", 
                      :title => '简单的设置，即可享用此大餐' 
                %>
                <% end %>
              <% end %>
              <%= link_to "编辑该吐司", edit_tool_url(@tool) if current_user.admin? %>
            <% else %>   
              <% if @tool.flash? %>   
                <% link_to tools_flash_url, :title => '直接开吃',:target => :_blank do %>
                  <%= image_tag "tools/enjoy.jpg" %>
                <% end %>         
              <% else %>
                <% if @tool.popup? %>
                <% link_to instance_eval("tools_#{@tool.code}_url(:default)"), :target => :_blank, :title => '简单的设置，即可享用此大餐' do %>
                  <%= image_tag "tools/enjoy.jpg" %>
                <% end %>
                <% else %>
                <% link_to new_session_url, :title => '简单的设置，即可享用此大餐' do %>
                  <%= image_tag "tools/enjoy.jpg" %>
                <% end %>
                <% end %>
              <% end %>
            <% end %>
            </div>
          </div>
        </div>        
        <div class='bottom_corner'>
          <div class="left"></div>
          <div class="right"></div>
        </div>        
      </div>
      <div class='enjoy'>
        <div>
          <%= link_to_function "加入收藏夹", 
                "add_favorite('#{tool_url @tool}','麦吐司网-吐司-#{@tool.name}')", 
                :class => 'to_favorite' 
           %>
        </div>
        <div class='copy_to'>
          <div>转帖到</div>
          <div>
            <select id="share_to_others" onchange='share()'>
			        <option value="" selected>--请选择--</option>
			        <option value="baidu">百度空间</option> 
			        <option value="qqzone">QQ空间</option> 
  					  <option value="kaixin001">开心网</option>
  					  <option value="renren">人人网</option> 
  					  <option value="weibo">新浪微博</option> 
  					  <option value="douban">豆瓣</option> 
  					</select>
      	  </div>
        </div>
        <div>
          <%= link_to_function "复制链接", "copy_to_clipboard('#{tool_url @tool}')", :class => 'copy_link' %>
        </div>
        <div>
          <iframe id='renren_like' src="http://www.connect.renren.com/like?url=<%= u tool_url(@tool) %>" scrolling="no" frameborder="0" allowTransparency="true"></iframe> 
        </div>
      </div>
    </div>
    <div id='body' class='body'>
      <div class='sub_nav_bar'>
        <div id='sub_nav_bar_item_detail' class='h item'>
          <%= link_to_function "吐司详情", "show_or_hide('detail')", :title => '特色、特点' %>
          <span>Intr...！</span>
        </div>
        <%#*<div id='sub_nav_bar_item_options' class='item'>%>
          <%#= link_to_function "评论详情", "show_or_hide('options')", :title => '看看大伙都怎么评价它' %>
          <%#*<span>Opt...！</span>%>
        <%#*</div>%>
        <%#*<div id='sub_nav_bar_item_qas' class='item'>%>
          <%#= link_to_function "有问必答", "show_or_hide('qas')", :title => '有何疑问直接问吧' %>
          <%#*<span>Q&A！</span>%>
        <%#*</div>%>
        <% if @tool.code.zhui_tian_ya? %>
          <% if has_logined_by_user? %>
        <div id='sub_nav_bar_item_my_zhui' class='item'>
          <%= link_to_function "我追天涯", "show_or_hide('my_zhui')", :title => '我正在追的天涯帖子' %>
          <span>Mine！</span>
        </div>
        <% end %>
        <div id='sub_nav_bar_item_new_and_hot' class='item'>
          <%= link_to_function "最新最热", "show_or_hide('new_and_hot')", :title => '正在追踪的天涯最新、最热的帖子' %>
          <span>N&H！</span>
        </div>
        <% elsif @tool.code.open_apis? %>
        <% else %>
        <div id='sub_nav_bar_item_my_setting' class='item'>
          <%= link_to_function "我的设置", "show_or_hide('my_setting')", :title => '有关这个吐司的定制信息' %>
          <span>Mine！</span>
        </div>
        <% end %>
      </div>
      <div id='tools'>
        <div>
          <div id="detail" class='tool'>
            <div class='block'>
              <h2>详细介绍：</h2>
              <div class='content'>
                <%= @tool.introduce %>
              </div>
            </div>
            <div class='block'>
               <h2>版本说明：</h2>
               <div class='content'>            
                 <%= @tool.version_statement %>
               </div>             
            </div>
            <%#*<div class='block'>%>
              <%#*<h2>截图：</h2>%>
              <%#*<div class='content'>%>
                 <%#*<img width="135" height="180" src="http://u5.mm-img.com/rs/res/1/98034/sence2 240X320.jpg">%>
                 <%#*<img width="135" height="180" src="http://u5.mm-img.com/rs/res/1/98034/sence2 240X320.jpg">%>
                 <%#*<img width="135" height="180" src="http://u5.mm-img.com/rs/res/1/98034/sence2 240X320.jpg">%>
                 <%#*<img width="135" height="180" src="http://u5.mm-img.com/rs/res/1/98034/sence2 240X320.jpg">%>
                 <%#*<img width="135" height="180" src="http://u5.mm-img.com/rs/res/1/98034/sence2 240X320.jpg">%>
              <%#*</div>%>
            <%#*</div>%>
          </div>
        </div>
        <div>
          <div id="options" class='h tool'>            
            <div class='line'>
              <div id='new_or_edit_option'>
                <div>
                <form action="show_submit" method="get" accept-charset="utf-8">
                  <dl>
                    <dt>评分:</dt>
                    <dd>
                      <select>
                        <option value='5'>★★★★★ 很棒
                        <option value='4'>★★★★ 较好
                        <option value='3'>★★★ 还好
                        <option value='2'>★★ 一般般
                        <option value='1'>★ 很烂
                      </select>
                    </dd>
                  </dl>                                    
                  <dl>
                    <dt>评论：</dt>
                    <dd>
                      <textarea id="commentInput" rows="" cols="" name="content"></textarea>
                    </dd>
                  </dl>
                </form>
                  <dl>
                    <dd>
                      <%= link_to_function "发表我的看法", "function", :class => :submit %>
                      <%= link_to_function "返回", "function", :class => :return %>
                    </dd>
                  </dl>
                </div>
              </div>
            </div>
            <div class='line'>
              <%= link_to_function "我也来评评", "index", :class => :new_option %>
            </div>
            <div class='line'>
              <% 5.times do %>
              <div class="option">
                <div class="logo"> 
                  <img width="32" height="32" align="left" src="http://www.gravatar.com/avatar.php?gravatar_id=29717c549ab2a8ecdc073ddb6281e29f&amp;size=32&amp;default=http://www.lepu.com/images/icon/no-gravatar.gif" alt="">       
                </div>
                <div class="right">
                  <div class='head'>                  
                    <div class='who'>
                      <%= link_to "七彩蝴蝶", "index" %>于三天前评到：
                    </div>
                    <div class='value'>                    
                      <b class="star_on">★</b>
                      <b class="star_on">★</b>
                      <b class="star_on">★</b>
                      <b class="star_on">★</b>
                      <b class="star_off">☆</b>              
                    </div>
                    <div class='edit_or_destroy'>
                      <%= link_to "修改", "index", :class => :edit %>
                      <%= link_to "删除", "index", :class => :destroy %>
                    </div>
                  </div>
                  <div class='content'>
                    7858moo:您如果是通过支付宝的话，可以在支付宝已买到的宝贝进行确认收货评价的，
                    谢谢您对乐铺的光顾，期待下次在为您服务！                  
                  </div>
                </div>
              </div>          
              <% end %>
            </div>
          </div>
        </div>
        <div>
          <div id="qas" class='h tool'>
            <div class='line'>
              <div id='new_or_edit_q'>
                <div>
                <form action="show_submit" method="get" accept-charset="utf-8">                     
                  <dl>
                    <dt>提问：</dt>
                    <dd>
                      <textarea id="commentInput" rows="" cols="" name="content"></textarea>
                    </dd>
                  </dl>
                </form>
                  <dl>
                    <dd>
                      <%= link_to_function "提交我的疑问", "function", :class => :submit %>
                      <%= link_to_function "返回", "function", :class => :return %>
                    </dd>
                  </dl>
                </div>
              </div>
            </div>
            <div class='line'>
              <%= link_to_function "我也有疑问", "index", :class => :new_q %>
            </div>
            <div class='line'>
              <% 5.times do %>
              <div class="qa">
                <div class="logo"> 
                  <img width="32"  height="32" align="left" src="http://www.gravatar.com/avatar.php?gravatar_id=29717c549ab2a8ecdc073ddb6281e29f&amp;size=32&amp;default=http://www.lepu.com/images/icon/no-gravatar.gif" alt="">       
                </div>
                <div class="right">
                  <div class='head'>                  
                    <div class='who'>
                      <%= link_to "七彩蝴蝶", "index" %>于三天前问到：
                    </div>
                    <div class='edit_or_destroy'>
                      <%= link_to "修改", "index", :class => :edit %>
                      <%= link_to "删除", "index", :class => :destroy %>
                    </div>
                  </div>
                  <div class='q'>
                    7858moo:您如果是通过支付宝的话，可以在支付宝已买到的宝贝进行确认收货评价的，
                    谢谢您对乐铺的光顾，期待下次在为您服务！                  
                  </div>
                  <div class='a'>
                    7858moo:您如果是通过支付宝的话，可以在支付宝已买到的宝贝进行确认收货评价的，
                    谢谢您对乐铺的光顾，期待下次在为您服务！<span class='a_info'>--回复于三天前</span>
                  </div>
                  <div class='q'>
                    7858moo:您如果是通过支付宝的话，可以在支付宝已买到的宝贝进行确认收货评价的，
                    谢谢您对乐铺的光顾，期待下次在为您服务！                    
                    <span class='a'><%= link_to "▶回复", "index" %></span>
                    <span class='q_info'>--发表于三天前</span>
                  </div>
                  <div class='a'>
                    7858moo:您如果是通过支付宝的话，可以在支付宝已买到的宝贝进行确认收货评价的，
                    谢谢您对乐铺的光顾，期待下次在为您服务！
                    <span class='c_q'><%= link_to "▶回复", "index" %></span>                    
                    <span class='a_info'>--回复于三天前</span>
                  </div>
                </div>
              </div>          
              <% end %>
            </div>
          </div>
        </div>
        <% if @tool.code.zhui_tian_ya? %>
        <div>
          <div id="my_zhui" class='h tool'>
            <script type="text/javascript" charset="utf-8">
              <%= remote_function :update => :my_zhui,
                    :url => my_zhui_tools_zhui_tian_ya_hot_posts_url,
                    :method => :get,
                    :loading => normal_loading('my_zhui', :height => '300px') if has_logined_by_user?
               %>
            </script>
          </div>
        </div>
        <div>
          <div id="new_and_hot" class='h tool'>
            <script type="text/javascript" charset="utf-8">
              <%= remote_function :update => :new_and_hot,
                    :url => new_and_hot_tools_zhui_tian_ya_hot_posts_url,
                    :method => :get,
                    :loading => normal_loading('new_and_hot', :height => '300px')
               %>
            </script>            
          </div>
        </div>
        <% elsif @tool.code.open_apis? %>
        <% else %>
        <div>
          <div id="my_setting" class='h tool'>
            <div class='line'>
              <div id='new_or_edit_my_setting'></div>
              <script type="text/javascript" charset="utf-8">
                <%= remote_function :update => :new_or_edit_my_setting,
                      :url => @tool.index_url_in_show,
                      :method => :get
                 %>
              </script>
            </div>
          </div>
        </div>
        <% end %>
      </div>
      <div id="items_related" class="span-19 last mb" >
        <div class="span-19 last title mb">› <b>您或者同样会喜欢</b>: </div>
        <ul class="itemlist1">
          <% @tool.others.each do |tool| %>
          <li>
            <div class='logo'>
              <% link_to tool_url(tool), :class => :b,:target => :_blank do %>
                <%= tool_logo_image_tag tool, :size => '120x140', :class => :hand %>
              <% end %> 
            </div>
            <div class="list_name">
              <%= link_to_tool tool, :target => :_blank %>
            </div>
          </li> 
          <% end %>                                   
        </ul>
      </div>
    </div>
  </div>
</div>
<%= render :file => 'homes/_guild.html' %>
<% if params[:target] == 'enjoy_or_not' and (not @tool.code.zhui_tian_ya?)  %>
  <script type="text/javascript" charset="utf-8">
    show_or_hide('my_setting');
    Effect.ScrollTo('my_setting',{duration:2.0});
  </script>
<% end %>
<script type="text/javascript" charset="utf-8">
  //show_or_hide('new_and_hot');
  //Effect.ScrollTo('new_and_hot',{duration:2.0});
</script>
<% if @tool.code.zhui_tian_ya? %>
  <% form_tag 'javascript:void(0);', :id => 'search_form'  do %>
  <%= hidden_field_tag :hot_post_type_id %>
  <%= hidden_field_tag :page %>
  <% end %>
  <% form_tag 'javascript:void(0);', :id => 'my_zhui_search_form'  do %>
  <%= hidden_field_tag :type_id %>
  <% end %>
<% end %>